<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise的基础书写</title>
</head>
<body>
    <script>
        /*
        执行顺序为: 先同步再异步,异步不会阻塞同步
            -开始A=>保存并打印=>p1接收到的promise实例返回值=>已掌握=>A成功
        */
        const p1 = new Promise((resolve,reject)=>{
            console.log("开始请求A数据");
            setTimeout(()=>{
                console.log("A数据请求成功");
            },3000)
            console.log("请保存Promise的值并打印出来");
        })

        //打印Promise实例对象的返回值
        /*
        p1的打印结果
        promise实例有两个属性:
           -promiseStat:penging 表示当前Promise实例的状态
           -promiseResult: undefined Promise实例的返回值
        */
        console.log("p1",p1);

        console.log("已掌握Promise的基础写法");
    </script>
</body>
</html>